<template lang="jade">
div
  h-loader-full(url='loader',:setdata='false')
  h-data-lister(data='list')
    m-title(icon="add",name="直播列表")
      input(type='text',placeholder='直播标题',v-model='name')
      button(@click='filter(p)') 过滤
    table.list
      ml-header(data='序号,标题,图片,链接:20,开始时间,状态,排序,操作')
      tr(v-for='(n,i) in list')
        td {{i+1}}
        td {{n.name}}
        td: img.img(:src="'http://image.mod.hesq.com.cn/xiongan/logo/'+ n.img")
        td {{n.href}}
        td {{new Date(n.time*1000).format('yyyy-MM-dd hh:mm:ss')}}
        //- td: input(type='checkbox',v-model='n.ishome')
        td(v-if='n.status == 0') 未开始
        td(v-if='n.status == 1') 进行中
        td(v-if='n.status == 2') 已结束
        td: input(type='text',v-model='n.sort')
        td
          a(href='javascript:void(0)',class='update',:data-index='i') 更新
          a(:href="'live_edit.html?id='+n.id") 编辑
          a(href='javascript:void(0)',class='remove',:data-index='i',v-if='n.ishome==0') 删除
      .command
        .page
          button(@click="go('last')",v-show='page>1') 上一页
          button {{page}}
          button(@click="go('next')") 下一页
</template>
<script>
export default{
	data () {
		return {
      page:1,
      loader:{ 
        list:'live/list/history',
		  },
      url:{
        update:'live/update/sort',
        remove:'live/delete/manager'
      },
      name:'',
      list:[],
      ishome:''
		}
	},
	methods:{
    loadAfter(res){
      this.list = res.list
    },
    go(type){
			this.page = type == 'last' ? this.page - 1 : this.page + 1
			this.$ajax.get('live/list/history?page='+this.page,(res)=>{
				this.list = res.data
			},(res)=>{
        this.$msg.error(res.message)
			})
		},
    filter(p){
			this.$ajax.get('live/list/history?name='+ this.name + '&page=' + this.page,(res)=>{
				this.list=res.data
			},(res)=>{
				this.$msg.error(res.message)
			})
		},
    updateAfter(res) {
			this.$msg.success()
			setTimeout("window.location.reload()",1000)
		},
  }
}
</script>
<style>
.img{ width:100px; height:50px!important;}
</style>